<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>ws</title>
<script type="text/javascript">
// 创建一个Socket实例
var socket = new WebSocket('ws://182.254.135.131:9002'); 

// 打开Socket 
socket.onopen = function(event) { 
  // 发送一个初始化消息
  socket.send('hello world'); 
  console.log("connected");
};

// 监听消息
socket.onmessage = function(event) { 
	console.log('msg:',event); 
}; 
  
// 监听Socket的关闭
socket.onclose = function(event) { 
	console.log('close:',event); 
};

//error
socket.onerror = function(event) { 
	console.log('error:',event); 
};  
</script>
</head>
<body>
</body>
</html>